package com.shopping.product.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.*;

@Configuration
public class ThreadPoolConfig {

    @Bean
    public ThreadPoolExecutor threadPoolExecutor() {
        BlockingQueue<Runnable> queue = new LinkedBlockingQueue<>(100000);
        ThreadFactory threadFactory = Executors.defaultThreadFactory();
        ThreadPoolExecutor.AbortPolicy policy = new ThreadPoolExecutor.AbortPolicy();
        return new ThreadPoolExecutor(20, 200, 10, TimeUnit.SECONDS, queue, threadFactory, policy);
    }

}
